package main

import "fmt"

func Map() {
	//声明1
	var m map[string]string
	//第一个声明这个一定要赋值才行
	m = map[string]string{}
	m["name"] = "gt"
	m["性别"] = "男"

	//声明2
	m1 := map[int]bool{}
	m1[3] = true
	m1[7] = false

	//声明3
	m2 := make(map[int]string)
	m2[1] = "gt"
	m2[2] = "男"

	fmt.Println(m, m1, m2)

	//使用interface
	m3 := map[int]interface{}{}
	m3[1] = 1
	m3[2] = "gaotao"
	m3[3] = []int{1,2,3,4}
	fmt.Println(m3, len(m3))

	//delete删除,长度减1
	delete(m3, 2)
	fmt.Println(m3, len(m3))

	//for range遍历
	for k,v := range m3{
		fmt.Println(k,v)
	}



}
